<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>业务流程管理列表</title>
    <jsp:include page="../../../head.jsp"/>
</head>
<script type="text/javascript">

    var processState = $.mrdForm.ajaxdp("process-processState");

    $(function () {
        $("#mrdForm").mrdForm({
                                  title: "查询列表",
                                  columns: [{
                                      name: "processName",
                                      label: "业务流程名称"
                                  }],
                                  buttons: {
                                      'custom': [
                                          {id: "addProcess", value: "添加业务流程", click: add},
                                          {id: "modify", value: "编辑业务流程", click: edit}
                                      ]
                                  },
                                  grid: {
                                      id: "columnGrid",
                                      url: "process-listProcess?bizType=" + $(
                                              "#bizType").val(),
                                      colNames: ["id", "流程名称", "状态", "备注"],
                                      colModel: [{
                                          name: 'processId',
                                          index: 'processId',
                                          hidden: true,
                                          align: 'center'
                                      }, {
                                          name: 'processName',
                                          index: 'processName',
                                          label: '流程名称',
                                          align: 'center'
                                      }, {
                                          name: 'processState',
                                          index: 'processState',
                                          label: '状态',
                                          align: 'center',
                                          dropdown: processState
                                      }, {
                                          name: 'remarks',
                                          index: 'remarks',
                                          label: '备注',
                                          align: 'center'
                                      }],
                                      title: "业务流程列表",
                                      jsonReader: {
                                          //从哪个json对象中取值
                                          id: "processId"
                                      },
                                      onSelectRow: function (processId) {
                                      },
                                      ondblClickRow: function (id) {
                                          location.href =
                                                  ".../base/process-manage?process.processId=" + id
                                                  + "&process.bizType=" + $("#bizType").val();
                                      }
                                  }
                              });
        $("#mrdForm").mrdForm("resize");
    });

    function add() {
        location.href = "process-manage?bizType=" + $("#bizType").val();
    }

    function edit() {
        var selected_rowid = $("#columnGrid").jqGrid("getGridParam", "selrow");
        if (!selected_rowid || selected_rowid == "" || selected_rowid == null) {
            alert("请选择需要编辑的业务流程");
            return;
        }
        var rowData = $("#columnGrid").getRowData(selected_rowid);
        location.href =
                "process-manage?processId=" + rowData.processId + "&bizType=" + $(
                        "#bizType").val();
    }
</script>
<body>
<input type="hidden" id="bizType" value="${process.bizType}"/>
<div id="mrdForm"></div>
</body>
</html>
